<template>
    <div>
        <Modal
         title="查看地区"
         :value="value"
         :width="95"
         @on-cancel="cancel"
         :mask-closable="false"
        >
            <Form :ref="formRef" :rules="rules" :model="model" :label-width="100">
                <FormItem label="商品ID" prop="id">
                    <Input v-model="model.id" size="small" :maxlength="32" :minlength="2" disabled w10 />
                </FormItem>
            </Form>

            <div slot="footer">
                <Button @click="cancel">取消</Button>
                <Button @click="save" type="primary">添加</Button>
            </div>
        </Modal>
    </div>
</template>
<script lang="ts">
import { Component, Vue,Inject, Prop,Watch } from 'vue-property-decorator';
import AbpBase from '../../lib/abpbase'

@Component({
    components: { }
})
export default class OrderUpdate extends AbpBase{
    @Prop({type:Boolean,default:false}) value:boolean
    formRef = this.getRandomRef('form')
    model:any = {}
    rules = {
        name:[{required: true,message:"请添加商品名称",trigger: 'blur'}]
    }
    save(){
        this.validate(this.formRef, async ()=>{
            let response = await this.post("Commodity/CreateCommodity", this.model);
            if(response.success) {
                this.$emit('save-success');
                this.closeModal();
            }
        })
    }
    cancel(){
        this.closeModal();
    }
    closeModal() {
        (this.$refs[this.formRef] as any).resetFields();
        this.$emit('input', false);
    }
}
</script>